package Test;

import javax.swing.*;
import java.awt.*;

public class GridLayOutTest {
    private  static  void  Test04(){
        JFrame frame = new JFrame("GridLayOutTest");
        frame.setLayout(new GridLayout(3,3));  //设定网格布局管理，窗体为（3*3）
        frame.setSize(600,600);
        frame.setLocation(200,200);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        //遍历创建、添加按钮组件
        for (int i=0;i<10;i++){
            JButton jButton = new JButton("按钮"+(i+1));
            frame.add(jButton);
        }
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(GridLayOutTest::Test04);
    }
}
